/*
 * PassoDeTempo.c
 *
 *  Created on: 10/08/2012
 *      Author: joserobertosteiner
 */


#include <stdio.h>
#include <stdlib.h>

#define  B0   0.675603595979828813
#define  B1  -0.175603595979828813
#define  D0   1.35120719195965763
#define  D1  -1.70241438391931525

int PassoDeTempo(long nmax, double dt, double *magnetx, double *magnety, double x[], double v[], double f[]){

	long n;
	double magx, magy;

	for (n = 0 ; n < nmax ; n++){
		v[n] = v[n] + B0*dt+f[n];
		x[n] = x[n] + D0*dt*v[n];
	}

	ForceHMF(nmax, &magx, &magy, x, f);
	for (n = 0 ; n < nmax ; n++){
		v[n] = v[n] + B1*dt+f[n];
		x[n] = x[n] + D1*dt*v[n];
	}

	ForceHMF(nmax, &magx, &magy, x, f);
	for (n = 0 ; n < nmax ; n++){
		v[n] = v[n] + B1*dt+f[n];
		x[n] = x[n] + D0*dt*v[n];
	}

	ForceHMF(nmax, &magx, &magy, x, f);
	for (n = 0 ; n < nmax ; n++){
		v[n] = v[n] + B0*dt+f[n];
	}

	*magnetx = magx;
	*magnety = magy;

	return EXIT_SUCCESS;
}
